home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyo (Python 2.5) from __future__ import with_statement import os.path as os import wx import sys import logging import platform from time import time from path import path from traceback import print_exc, print_stack from contextlib import closing from logging import getLogger log = getLogger() IDLE_CHECK_MS = 2000 IDLE_CHECK_MOUSE_DISTANCE = 10 LOG_FILENAME = 'digsby.log.csv' LOG_SPEED_LIMIT = 0.4 * 1024 * 1024 LOG_SPEED_WINDOW = 10 USE_HANGING_THREAD_DAEMON = True EXIT_TIMEOUT_SECS = 10 TASKBAR_REFRESH_MS = 5 * 60 * 1000 if not getattr(sys, 'REVISION', 'dev') != 'dev' and '--multi' not in sys.argv: pass USE_SINGLE_INSTANCE = '--single' in sys.argv APP_NAME = u'Digsby' def init_threadpool(): if getattr(wx, 'WXPY', False): add_before_cb = add_before_cb add_after_cb = add_after_cb import util.threads add_before_cb(wx.SipNewThread) add_after_cb(wx.SipEndThread) ThreadPool = ThreadPool import util ThreadPool(5) if USE_SINGLE_INSTANCE: from singleinstance import SingleInstanceApp DigsbyAppBase = SingleInstanceApp else: DigsbyAppBase = wx.App class DigsbyApp(DigsbyAppBase): def OnFatalException(self): try: where_string = where_string import common.commandline print >>sys.stderr, where_string(duplicates = True) sys.stderr.flush() except Exception: e = None print_exc() def __init__(self): if USE_SINGLE_INSTANCE: DigsbyAppBase.__init__(self, appname = APP_NAME, redirect = False) else: DigsbyAppBase.__init__(self, redirect = False) self.global_hotkeys = { } self.next_hotkey_id = 0 self.PreShutdown = [] def Restart(self): self.restarting = True self.DigsbyCleanupAndQuit() def AfterStartup(self): if getattr(self, '_afterstartup', False): return None self._afterstartup = True log.info('AfterStartup') import socks import util import wx import util.callbacks as util util.callbacks.register_call_later('MainThread', wx.CallAfter) socks.setdefaultproxy(**util.GetProxyInfo()) if 'wxMSW' in wx.PlatformInfo: self.setup_fullscreen() self.init_hotkeys() init_threadpool() import wx if 'wxMSW' in wx.PlatformInfo and sys.opts.cpuwatch: CPUWatch = CPUWatch import util.perfmon self.cpu_watcher = CPUWatch() try: try: import webview except ImportError: import wx.webview as wx except Exception: print >>sys.stderr, 'Warning: error preloading webkit' if 'wxMSW' in wx.PlatformInfo: import util.checkoptions as util util.checkoptions.start_checking() def OnInit(self): set_app_info(self) self.Bind(wx.EVT_POWER_SUSPENDED, self.OnSuspend) self.Bind(wx.EVT_POWER_RESUME, self.OnResume) self.Bind(wx.EVT_MENU, self.DigsbyCleanupAndQuit, id = wx.ID_EXIT) wx.IdleEvent.SetMode(wx.IDLE_PROCESS_SPECIFIED) wx.UpdateUIEvent.SetMode(wx.UPDATE_UI_PROCESS_SPECIFIED) wx.SystemOptions.SetOptionInt('mac.textcontrol-use-mlte', 1) wx.SystemOptions.SetOptionInt('mac.textcontrol-use-spell-checker', 1) if os.name == 'nt': self.setup_crash_reporting() import stdpaths stdpaths.init_wx() sys.comtypes_dir = stdpaths.userlocaldata self.SetExitOnFrameDelete(False) return True def init_plugins_pythonpath(self): import stdpaths sys.path.extend((lambda .0: for p in .0: p.abspath())((stdpaths.userdata / 'Plugins').files('*.egg'))) def GetCmdLine(self): exe = sys.executable.decode(sys.getfilesystemencoding()) if getattr(sys, 'frozen', False) == 'windows_exe': args = sys.argv[1:] else: args = sys.argv[:] return ' '.join([ exe] + args) def setup_crash_reporting(self, username = None): if not sys.opts.crashreporting: print >>sys.stderr, 'Crash reporting is disabled.' return None crash_cmd = self.GetCmdLine() crash_cmd += ' --crashreport %s' if username is not None: crash_cmd += ' --crashuser %s' % username self.SetCrashCommand(crash_cmd) if sys.opts.full_crashdump: flag = wx.CRASH_REPORT_LOCATION | wx.CRASH_REPORT_STACK | wx.CRASH_REPORT_LOCALS | wx.CRASH_REPORT_GLOBALS self.crash_report_flags = flag crashdump_dir = sys.opts.crashdump_dir if crashdump_dir: isdir = isdir abspath = abspath pathjoin = join normpath = normpath import os.path try: crashdump_dir = abspath(crashdump_dir) if not isdir(sys.opts.crashdump_dir): os.makedirs(crashdump_dir) except Exception: print_exc() if not username: pass filename = 'Digsby_%s_%s.dmp' % ('', str(time())) filename = normpath(pathjoin(crashdump_dir, filename)) wx.CrashReport.SetFileName(filename) print >>sys.stderr, 'Dumpfile: %r' % wx.CrashReport.GetFileName() wx.HandleFatalExceptions() def OnSuspend(self, e): profile = profile import common p = profile() if p is not None: p.hibernate() def OnResume(self, e): profile = profile import common p = profile() if p is not None: p.unhibernate(20) def setup_fullscreen(self): FullscreenApp = FullscreenApp import gui.native.helpers imhub = imhub import gui.imwin RepeatTimer = RepeatTimer Delegate = Delegate import util self.on_fullscreen = Delegate() self._fs_app_running = None((RepeatTimer, 1), (lambda : (None, wx.CallAfter)((lambda : self.on_fullscreen(FullscreenApp()))) )) self._fs_app_running.start() (self.on_fullscreen,) += (lambda val: None if not val else None) finish_init = False def ShowSplash(self, autologin_override = None, kicked = False): splash = DigsbySplash import digsbysplash log = getLogger('splash') self.OnBuddyListShown = [] def splash_success(info): self.AfterStartup() import digsbyprofile def signin_success(on_gui_load): wx.CallAfter(self.FinishInit, on_gui_load) def signin_error(err = (None, None, (None,), None)): if getattr(self, 'finish_init', False): log.info('signin error on reconnect') conn = digsbyprofile.profile oldcon = conn.connection protocol = protocol import common try: conn.connection.offline_reason = protocol.Reasons.CONN_FAIL log.info('conn.connection1 %r', conn.connection) except AttributeError: log.info('conn.connection2 %r', conn.connection) conn.offline_changed(None, 'offline_reason', None, protocol.Reasons.CONN_FAIL) try: conn.connection.change_state(protocol.Statuses.OFFLINE) log.info('conn.connection3 %r', conn.connection) except AttributeError: log.info('conn.connection4 %r', conn.connection) conn.connection_state_changed(oldcon, 'state', protocol.Statuses.CONNECTING, protocol.Statuses.OFFLINE) conn.account_manager.on_offline_change(conn, None, None, None) else: s.proto_error(err) return digsbyprofile.signin(info['username'], info['password'], success = signin_success, error = signin_error) s = splash(splash_success, autologin_override = autologin_override) self._splash = s self.SetTopWindow(s) def aftershown(): s.Show() s.Update() wx.CallAfter(aftershown) if kicked: wx.CallAfter(wx.MessageBox, message = _('Your digsby password has been changed. Please log back in with the new password.'), caption = _('Password Changed')) self.finish_init = False return True def SetupTaskbarIcon(self): BuddyListTaskBarIcon = BuddyListTaskBarIcon import gui.buddylist.buddylistframe skin = skin import gui icon = skin.get('AppDefaults.TaskbarIcon') self.tbicon = None(BuddyListTaskBarIcon, icon = 'tooltip' if not getattr(sys, 'DEV', None) else 'Digsby DEV') if 'wxMSW' in wx.PlatformInfo: self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnShowHideBuddylist) refresh = lambda : self.tbicon.SetIcon(icon) self.tray_refresh_timer = wx.PyTimer(refresh) self.tray_refresh_timer.StartOneShot(TASKBAR_REFRESH_MS) def FinishInit(self, on_gui_load = None): import digsbyprofile profile = digsbyprofile.profile if self.finish_init: return profile.connection.change_state(profile.connection.Statuses.ONLINE) self.finish_init = True splash = self._splash del self._splash if splash.cancelling: return profile.disconnect() def get_rid_of_splash(): try: saveWindowPos = saveWindowPos import gui.toolbox saveWindowPos(splash) splash.Show(False) finally: splash.Destroy() get_rid_of_splash = (wx.CallAfter,)(get_rid_of_splash) autologin = False if not wx.GetKeyState(wx.WXK_SHIFT): autologin = True import gui.skin as gui gui.textutil.default_font() (wx.CallAfter,)((lambda : list(gui.textutil.GetFonts()))) if 'wxMSW' in wx.PlatformInfo: set_comtypes_gendir = set_comtypes_gendir import gui.native.win.winutil wx.CallAfter(set_comtypes_gendir) path = path import path gui.skin.skintree.resource_paths.append(path(wx.StandardPaths.Get().GetUserDataDir())) changeskin = gui.skin.set_active def on_skin_load(): self.PostSkin(autologin = autologin, success = on_gui_load) profile.connection.change_state(profile.connection.Statuses.ONLINE) profile._have_connected = True if os.name == 'nt': self.setup_crash_reporting(username = profile.username) pref = pref import common changeskin(pref('appearance.skin'), pref('appearance.variant'), callback = on_skin_load) def PostSkin(self, autologin = False, success = None): BuddyListFrame = BuddyListFrame import gui.buddylist.buddylistframe self.buddy_frame = BuddyListFrame(None, title = _('Buddy List'), name = 'Buddy List', style = wx.DEFAULT_FRAME_STYLE | wx.FRAME_NO_TASKBAR) def muchlater(): self.idletimer = wx.PyTimer(self.not_idle) self.idletimer.Start(IDLE_CHECK_MS) def show_buddylist_frame(): self.buddy_frame.Show(True) self.SetTopWindow(self.buddy_frame) Delegate = Delegate import util Delegate(self.OnBuddyListShown)(autologin = autologin) del self.OnBuddyListShown[:] def memevent(): memory_event = memory_event import gui.native memory_event() wx.CallLater(60000, memevent) platformName = platformName import config if platformName == 'win': page_out_ram = page_out_ram import gui.native.win.process wx.CallLater(1000, page_out_ram) wx.CallAfter(show_buddylist_frame) wx.CallAfter(muchlater) self.SetupTaskbarIcon() def MacOpenFile(self, filename): log.info('File dragged to dock icon: ' + filename) def toggle_prefs(self): import digsbyprofile if not hasattr(digsbyprofile, 'profile') or digsbyprofile.profile is None: return wx.MessageBox(_('Please login first.'), _('Advanced Preferences')) pref = pref import common if not __debug__ and sys.REVISION == 'dev' or pref('debug.advanced_prefs', False): return None profile = digsbyprofile.profile import prefs if not self.buddy_frame: pass prefs.edit(profile.prefs, profile.defaultprefs, None) def toggle_crust(self): pref = pref import common if not getattr(sys, 'DEV', False): pass can_show_console = pref('debug.console', False) if not can_show_console: return None self.make_crust() self.crust.toggle_shown() if self.crust.IsShown(): self.crust.FocusInput() def make_crust(self): if not hasattr(self, 'crust') or not (self.crust): import gui tlws = wx.GetTopLevelWindows() self.crust = gui.PyCrustFrame(None) if tlws: parent = tlws[0] parent.crust = self.crust def toggle_sorting(self): profile = profile import common prefs = profile.prefs if prefs: if prefs.get('buddylist.allow_sorting_change', False): prefs['buddylist.sorting'] = not prefs.get('buddylist.sorting', True) def not_idle(self, e = None): pref = pref profile = profile import common import digsbyprofile as d if not profile.prefs: return None set_idle_after = pref('messaging.idle_after', 20 * d.IDLE_UNIT, type = int) GetUserIdleTime = GetUserIdleTime import gui.native.helpers t = GetUserIdleTime() if t < set_idle_after * 1000: profile.reset_timers() profile.return_from_idle() self.idletimer.Start() def OnSaved(self): log.info('profile.save SUCCESS, shutting down') return self.do_shutdown() def OnSaveError(self): log.warning('error saving blobs') return self.do_shutdown() def DigsbyCleanupAndQuit(self, e = None): traceguard = traceguard Delegate = Delegate import util log.info('DigsbyCleanupAndQuit') if getattr(self, 'shutting_down', False): return None self.shutting_down = True Delegate(self.PreShutdown)() log.info(' saving and disconnecting profiles and accounts') traceguard.__enter__() try: log.info('destroying main tray icon...') if getattr(self, 'tbicon', None) is not None: self.tbicon.Destroy() self.tbicon = None frame = getattr(self, 'buddy_frame', None) if frame: if frame.IsShown(): frame.on_close(exiting = True) log.info('destroying %r', frame) frame.on_destroy() traceguard.__enter__() try: popup = popup import gui popup.cancel_all() finally: pass for tlw in wx.GetTopLevelWindows(): tlw.Close(True) finally: pass profile = profile import digsbyprofile if profile and profile.connection: profile.save(success = self.OnSaved, error = self.OnSaveError) else: self.OnSaved() def OnExit(self, event = None): log.info('OnExit') log.info(' replacing wx.CallAfter') wx.CallAfter = lambda f, *a, **k: f(*a, **k) def do_shutdown(self): traceguard = traceguard import util log.info('do_shutdown') traceguard.__enter__() try: if USE_SINGLE_INSTANCE: self.StopSingleInstanceServer() finally: pass traceguard.__enter__() try: timer = getattr(self, 'tray_refresh_timer', None) log.info(' ok') finally: pass dbg = log.debug info = log.info def _after_disconnect(): info('joining with TimeoutThread') traceguard.__enter__() try: timeout_thread = timeout_thread import util.threads timeout_thread.join() finally: pass info('joined with TimeoutThread') info('joining with AsyncoreThread') traceguard.__enter__() try: import AsyncoreThread AsyncoreThread.end_thread() AsyncoreThread.join() finally: pass info('joining ThreadPool') ThreadPool = ThreadPool import util ThreadPool().joinAll() info('done joining ThreadPool') dbg('clean exit.') self.ExitMainLoop() dbg('disconnecting profile') traceguard.__enter__() try: profile = profile import common if profile and hasattr(profile, 'disconnect'): profile.disconnect(success = _after_disconnect) else: _after_disconnect() finally: pass def init_hotkeys(self): input = input_manager import gui.input.inputmanager skin = skin import gui platformName = platformName import config input.AddGlobalContext(_('Global Shortcuts'), 'Global') if getattr(sys, 'DEV', False): input.AddGlobalContext(_('Debug Global Shortcuts'), 'Debug') input.AddClassContext(_('Text Controls'), 'TextControls', wx.TextCtrl) resdir = skin.resourcedir() KEYS_YAML = 'keys.yaml' yaml_sources = (resdir / KEYS_YAML, resdir / platformName / KEYS_YAML) for yaml in yaml_sources: if yaml.exists(): log.info('loading keyboard shortcuts from %s', yaml) input.LoadKeys(yaml) continue actions = [ ('TextControls.SelectAll', (lambda textctrl: textctrl.SetSelection(-1, -1))), ('TextControls.DeletePreviousWord', 'gui.toolbox.DeleteWord'), (('Global.DigsbyShell.ToggleShow',), (lambda win: self.toggle_crust())), (('Global.AdvancedPrefs.ToggleShow',), (lambda win: self.toggle_prefs())), (('Global.Skin.Reload',), (lambda win: skin.reload())), (('BuddyList.Sorting.Toggle',), (lambda win: self.toggle_sorting())), ('Debug.XMLConsole', 'common.commandline.xmlconsole'), ('Debug.JavaScriptConsole', 'gui.browser.jsconsole.show_console')] addcb = input.AddActionCallback for name, action_cb in actions: addcb(name, action_cb) input.BindWxEvents(self) def AddGlobalHotkey(self, keys, callback): id = self.next_hotkey_id self.next_hotkey_id += 1 keycodes = keycodes import gui.toolbox (modifiers, key) = keycodes(keys) self.buddy_frame.RegisterHotKey(id, modifiers, key) self.buddy_frame.Bind(wx.EVT_HOTKEY, callback, id = id) self.global_hotkeys[(modifiers, key, callback)] = id def RemoveGlobalHotkey(self, keys, callback): keycodes = keycodes import gui.toolbox (modifiers, key) = keycodes(keys) id = self.global_hotkeys.pop((modifiers, key, callback)) self.buddy_frame.UnregisterHotKey(id) def should_check_for_updates(self): retval = True reason = None if not sys.opts.allow_update: retval = False reason = 'sys.opts.allow_updates == False' if platform.platform().find('Windows-2000') != -1: retval = False reason = 'Windows 2000' if not retval: log.info('Not checking for updates because: %r', reason) return retval def _manifest_path_from_yaml(self, yaml_loc): import syck import urllib2 urlopen_ts = urlopen_ts import AutoUpdate try: response = urlopen_ts(yaml_loc) except urllib2.URLError: e = None log.error('Couldnt get yaml (%r): %r', yaml_loc, e) return sentinel except Exception: e = None log.error('update failed: Error opening %r for reading. (%r)', yaml_loc, e) try: data = response.read() except Exception: return sentinel try: ui = syck.load(data) except Exception: print_exc() ui = None if ui is None: return sentinel platformName = platformName import config all = ui.get('all', { }) if not ui.get(platformName, None): pass mine = { } release_type = self._get_release_type() merged = all.copy() merged.update(mine) manifest_path = merged.get(release_type, merged.get('release', None)) if manifest_path is None: return sentinel else: return manifest_path def _get_release_type(self): import stdpaths tag = None try: try: f = _[2] tag = f.readline().strip() finally: pass except Exception: pass if not tag: tag = 'release' return tag def check_for_updates(self, manifest_path_path, success = None, error = None): import sys import hashlib import util.httplib2 as httplib2 import urlparse import path http_date_to_timestamp = http_date_to_timestamp urlopen_ts = urlopen_ts import AutoUpdate def try_and_whine(callable): try: result = callable() except Exception: print >>sys.stderr, 'error calling %s' % util.funcinfo(callable) print >>sys.stderr, 'giving up on update check' print_exc() return sentinel return result try: if manifest_path_path.endswith('.yaml'): manifest_location = self._manifest_path_from_yaml(manifest_path_path) else: manifest_location = (None, try_and_whine)((lambda : urlopen_ts(manifest_path_path).read())) except Exception: (None, None) (None, None) print_exc() manifest_location = sentinel except: (None, None) print >>sys.stderr, 'manifest location:', manifest_location if manifest_location is sentinel: return None if error is not None else None manifest_url = manifest_location conn = httplib2.Http() try: (headers, content) = conn.request(manifest_url, 'HEAD') except Exception: print_exc() headers = { } rmtime = headers.get('x-amz-meta-mtime', None) if rmtime is None: rmtime = headers.get('last-modified', None) if rmtime is not None: rmtime = http_date_to_timestamp(rmtime) if rmtime is not None: try: rmtime = int(rmtime) except (TypeError, ValueError): rmtime = None except: None<EXCEPTION MATCH>(TypeError, ValueError) None<EXCEPTION MATCH>(TypeError, ValueError) import util prog_dir = util.program_dir() mymanifest_path = path.path(prog_dir) / path.path(manifest_location).splitpath()[-1] print >>sys.stderr, mymanifest_path needs_update = True if mymanifest_path.exists(): lmtime = int(mymanifest_path.mtime) else: lmtime = 0 if lmtime == rmtime: print >>sys.stderr, 'Local MTime matches remote. Not downloading manifest. (local=%r, remote=%r)' % (lmtime, rmtime) needs_update = False else: print >>sys.stderr, 'MTime mismatch. Downloading manifest. (local=%r, remote=%r)' % (lmtime, rmtime) if mymanifest_path.exists(): mymanifest_digest = mymanifest_path.read_md5() else: mymanifest_digest = None manifest_resp = (None, try_and_whine)((lambda : urlopen_ts(manifest_location))) if manifest_resp is sentinel: return None if error is not None else None if 'gzip' in manifest_resp.headers.get('Content-Encoding', ''): import gzip import StringIO manifest_resp = gzip.GzipFile(fileobj = StringIO.StringIO(manifest_resp.read())) webman_hash = hashlib.md5() bytes = manifest_resp.read(8192) while bytes: webman_hash.update(bytes) bytes = manifest_resp.read(8192) manifest_resp.close() webdigest = webman_hash.digest() print >>sys.stderr, repr(mymanifest_digest), repr(webdigest), mymanifest_digest == webdigest if mymanifest_digest == webdigest: needs_update = False if sys.opts.force_update: needs_update = True if success is not None: success(needs_update, manifest_location) def OnRaiseBuddyList(self, e = None): frame = self.buddy_list docker = frame.docker if docker.AutoHide and docker.docked: if docker.autohidden: docker.ComeBack() frame.Raise() elif not frame.IsActive(): frame.Raise() def OnShowHideBuddylist(self, e = None): frame = self.buddy_frame docker = getattr(frame, 'docker', None) if docker is not None and frame.IsShown(): if getattr(docker, 'Enabled', False) and docker.docked: if docker.autohidden: docker.ComeBack() frame.Raise() return None shown = frame.Visible frame.Show(not shown) if not shown: if frame.IsIconized(): frame.Iconize(False) frame.Raise() class StdErrFilter(object): def filter(self, record): return record.name != 'stderr' class MyStdErr(object): has_stderr = True def write(self, s): try: self.stderrlog.error(s.rstrip()) except: pass if MyStdErr.has_stderr: try: sys.__stderr__.write(s) MyStdErr.has_stderr = False def flush(self): if MyStdErr.has_stderr: try: sys.__stderr__.flush() MyStdErr.has_stderr = False def get_logdir(): return os.path.join(wx.StandardPaths.Get().GetUserLocalDataDir(), 'Logs') def get_last_log_file_name(): return os.path.join(get_logdir(), LOG_FILENAME) def setup_log_system(): global full_loggers wx.Log.SetActiveTarget(wx.LogStderr()) if sys.opts.no_log: return None path = path import path import traceback DisablingStream = DisablingStream DelayedStreamLimiter = DelayedStreamLimiter LimitedFileSize = LimitedFileSize import fileutil sys.stdout = DisablingStream(sys.__stdout__) sys.stderr = MyStdErr() stderrlog = logging.getLogger('stderr') sys.stderr.stderrlog = stderrlog root = logging.Logger.root root.stream = sys.stderr root.setLevel(1) gzipFileHandler = gzipFileHandler CloseFileHandler = CloseFileHandler CSVFormatter = CSVFormatter CSV_HEADERS = CSV_HEADERS import csvlogging logdir = path(get_logdir()) if not logdir.exists(): logdir.makedirs() logfilebase = logfile = logdir / LOG_FILENAME N = 2 while True: try: f = open(logfile, 'wb') continue print_exc() logfile = logfilebase + ' (%d)' % N N += 1 if N > 100: raise AssertionError f = open(logfile, 'wb') continue sys.LOGFILE_NAME = logfile f.write(CSV_HEADERS) f.close() hdlr = CloseFileHandler(DelayedStreamLimiter(LimitedFileSize(sys.LOGFILE_NAME, 20971520, 10485760, initmode = 'ab'), limit = LOG_SPEED_LIMIT, window = LOG_SPEED_WINDOW)) hdlr.setFormatter(CSVFormatter()) full_loggers = [ hdlr] root.addHandler(hdlr) init_stdout() if not __debug__: logging.info('logger started - rev %s', sys.REVISION) print >>sys.stderr, 'testing stderr' print >>sys.stdout, 'testing stdout' class ConsoleFormatter(logging.Formatter): def format(self, record): if record.exc_info and not (record.exc_text): record.exc_text = self.formatException(record.exc_info) exc = None if record.exc_text else '' return ''.join([ '%-20s' % record.name, record.threadName[:4], '-', '%-4s | ' % record.levelname[:4], '%s' % record.getMessage(), exc]) def init_stdout(): DelayedStreamLimiter = DelayedStreamLimiter import fileutil console = None root = logging.Logger.root try: sys.stdout.write('Testing if sys.stdout is safe...\n') except: root.info('stdout disabled') root.info('stdout enabled') console = logging.StreamHandler(DelayedStreamLimiter(sys.stdout, limit = LOG_SPEED_LIMIT, window = LOG_SPEED_WINDOW)) console.setLevel(1) console.setFormatter(ConsoleFormatter()) if console is not None: logging.getLogger('').addHandler(console) if console is not None: console.addFilter(StdErrFilter()) startup_begin = 0 def check_dependencies(): try: import tlslite except ImportError: pass print >>sys.stderr, 'WARNING! tlslite is on PYTHONPATH, and will cause SSL problems. Please remove it: %r' % tlslite.__file__ def set_update_tag(): tag = sys.opts.updatetag if tag is not None: import stdpaths try: try: f = _[2] f.write(tag) f.write('\n') finally: pass except Exception: pass except: None<EXCEPTION MATCH>Exception None<EXCEPTION MATCH>Exception def main(): global startup_begin startup_begin = time() platformName = platformName import config if platformName == 'win' and sys.opts.crashreport: return send_crash_report() if sys.opts.profile: set_profilers_enabled = set_profilers_enabled import util set_profilers_enabled(True) digsby_app = DigsbyApp() wx.ConfigBase.Set(wx.FileConfig()) setup_log_system() log_system_info() digsby_app.ShowSplash() set_update_tag() if sys.opts.profile: currentThread = currentThread import threading use_profiler = use_profiler all_profilers = all_profilers import util if sys.opts.profile > 1: RepeatTimer = RepeatTimer import util def get_reports(): print '\n\n'.join((lambda .0: for p in .0: p.report())(all_profilers().itervalues())) digsby_app._profile_timer = RepeatTimer(30, get_reports) digsby_app._profile_timer.start() return use_profiler(currentThread(), digsby_app.MainLoop) else: return digsby_app.MainLoop() def send_crash_report(): a = wx.PySimpleApp() format_exc = format_exc import traceback set_app_info(a) CrashDialog = CrashDialog import crashgui msg = _('There was an error submitting your crash report.') try: diag = CrashDialog() diag.CenterOnScreen() diag.RequestUserAttention() if wx.ID_OK == diag.ShowModal(): import util.diagnostic as d last_log = get_last_log_file_name() diagobj = d.load_crash(sys.opts.crashreport, last_log, username = sys.opts.crashuser, description = diag.Description) if diagobj.succeeded: msg = _('Crash report submitted successfully.') else: return None except Exception: print_exc() msg += '\n\n' + _('Would you like to restart Digsby now?') if wx.YES == wx.MessageBox(msg, _('Crash Report'), style = wx.YES_NO | wx.YES_DEFAULT): cmd = sys.executable.decode(sys.getfilesystemencoding()) if not getattr(sys, 'frozen', False) == 'windows_exe': cmd += ' ' + sys.argv[0] wx.Execute(cmd) def log_system_info(): import locale startup_time = (time() - startup_begin) * 1000 info = log.info info('Digsby rev %s', sys.REVISION) info('started up in %s ms', startup_time) info(' '.join(wx.PlatformInfo) + ' wx v' + '.'.join((lambda .0: for c in .0: str(c))(wx.VERSION))) info('Platform: %r', ' '.join(platform.uname()).strip()) info('Python ' + sys.version) info('locale: ' + str(locale.getdefaultlocale())) info('user local data dir: %r', wx.StandardPaths.Get().GetUserLocalDataDir()) info('__debug__ is %r', __debug__) info('updatetag is %r', sys.opts.updatetag) def set_app_info(app): app.SetAppName(APP_NAME) app.SetVendorName(u'dotSyntax') app.SetAppName(APP_NAME) app.SetClassName(APP_NAME) if __name__ == '__main__': raise AssertionError('run Digsby.py')